Make your own free website on Tripod.com



/*  

foreach was added in DMD 0.71
http://www.digitalmars.com/d/statement.html#foreach

*/

class Foo
    {
        uint array[2];

        int apply(int delegate(inout uint) dg)
        {   int result = 0;


        for (int i = 0; i < array.length; i++)
        {
            result = dg(array[i]);
            if (result)
            break;
        }
        return result;
        }
    }



void test()
    {
        Foo a = new Foo();

        a.array[0] = 73;
        a.array[1] = 82;

        foreach (uint u; a)
        {
        printf("%d\n", u);
        }
    }


int main()
{
    test();
    return 0;

}